import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
import router from './router'
import store from './store'
import panelHead from './components/panelHead.vue'

router.beforeEach((to, from) => {
  const token = localStorage.getItem('pz_token')
  if (to.path !== '/login' && !token) {
    return '/login'
  }else if (to.path === '/login' && token) {
    return '/'
  }else{
    return true
  }
})

// 如果您正在使用CDN引入，请删除下面一行。
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

const app = createApp(App)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

app.component('panelHead', panelHead)
//路由挂载
app.use(router)
app.use(store)
app.mount('#app')
